PROP_DIC = {
    '黄门': {'key_yellow': -1},
    '蓝门': {'key_blue': -1},
    '红门': {'key_red': -1},
    '铁门': {None: None},
    '黄钥匙': {'key_yellow': 1},
    '蓝钥匙': {'key_blue': 1},
    '红钥匙': {'key_red': 1},
    '钥匙盒': {'key_yellow': 1, 'key_blue': 1, 'key_red': 1},
    '红药': {'HP': 200},
    '蓝药': {'HP': 500},
    '红宝石': {'attack': 3},
    '蓝宝石': {'defend': 3},
    '铁剑': {'attack': 10},
    '青锋剑': {'attack': 70},
    '星光神剑': {'attack': 150},
    '铁盾': {'defend': 10},
    '钢盾': {'defend': 85},
    '光芒神盾': {'defend': 190},
    '大金币': {'money': 300},
    '小飞羽': {'level': 1, 'HP': 1000, 'attack': 10, 'defend': 10},
    '大飞羽': {'level': 3, 'HP': 3000, 'attack': 30, 'defend': 30},
    '2楼老头': {'attack': 70},
    '2楼老太': {'attack': 30},
}
FLOOR_DIC = {
    '上楼': 1,
    '上23楼左': 3,
    '上23楼右': 4,
    '下楼': -1,
    '下22楼': None,
}
# 楼层跳跃备用坐标字典
up_down_pos = {0: [(5, 8)], 1: [(5, 9), (1, 0)], 2: [(0, 1), (0, 9)], 3: [(1, 10), (10, 9)],
               4: [(10, 9), (0, 9)], 5: [(1, 10), (9, 9)], 6: [(8, 10), (5, 10)], 7: [(5, 10), (1, 0)],
               8: [(0, 1), (7, 4)], 9: [(6, 3), (6, 7)], 10: [(4, 6), (0, 9)], 11: [(1, 10), (9, 10)],
               12: [(9, 10), (1, 10)], 13: [(1, 10), (4, 10)], 14: [(5, 9), (5, 0)], 15: [(3, 0), (7, 0)],
               16: [(5, 0), (5, 6)], 17: [(5, 8), (1, 10)], 18: [(1, 10), (9, 10)], 19: [(9, 10), (5, 4)],
               20: [(5, 4), (5, 6)], 23: [(5, 7)]}
# 商店近似最优选择策略，0防1攻
money_shop_count_ls = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
money_shop_count_ls_11 = [0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0,
                          0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                          1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
                          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                          1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
exp_shop_count_ls = [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                     0, 0, 0, 0, 0, 0, 0]
exp_shop_count_ls_13 = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0,
                        0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
                        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
# 近似最优路径记录
step_ls1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 3]
step_1_2 = [0, 0, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
step_ls2 = [0, 0, 2, 0, 0, 0, 0, 0, 2, 2, 1, 0, 2, 2, 1]
step_3_4 = [0, 3, 3, 3, 0, 0, 2, 2, 2, 2, 0, 0, 0, 3, 3, 1, 3, 3, 3, 3, 1, 3, 3, 0, 0, 0, 0, 0, 3, 3, 1, 1, 1, 1, 1, 1,
            1, 1, 1]
step_ls3 = [0, 0, 0, 0, 2, 3, 3, 1, 1, 2, 2, 3, 1, 1]
step_ls4 = [1, 1, 2, 1, 1, 3, 3, 0, 1, 2, 2, 0, 0, 3, 0, 0]
step_ls5 = [2, 0, 0, 0, 2, 0, 0, 0]
step_ls6 = [0, 0, 0, 2, 3, 1, 1, 1]
step_ls7 = [1, 1, 3, 2, 0, 0]
step_ls8 = [1, 1, 1, 0, 0, 0]
step_4_5 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
step_ls9 = [0, 2, 2, 1]
step_5_6 = [3, 1, 3, 3, 3, 3, 0, 0, 0, 3, 3, 1, 1, 3, 3, 1]
step_6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, 0]
step_10_11 = [2, 2, 0, 0, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1]
step_ls23 = [3, 3, 3, 3, 0, 0]
step_ls24 = [0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3, 0, 0, 2, 0, 0, 0]
step_ls25 = [3, 3, 1, 1, 2, 0, 0, 2, 2]
step_ls26 = [2, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 3]
step_ls27 = [3, 3, 0, 0, 3, 3, 3, 1, 1, 1, 1, 1, 1, 2]
step_ls28 = [2, 2, 0, 0, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 1, 1, 0, 0, 3, 3, 1, 1, 0, 0, 2, 0, 0, 3, 3, 3, 0, 0, 1, 1, 1, 1,
             1, 1]
step_ls29 = [0, 2, 0, 0, 2, 2, 1, 1, 1, 2, 2, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 1, 1,
             2, 2, 2, 0, 0, 3, 1, 1, 3, 3, 3, 3, 3, 3, 0, 0, 2, 2, 1, 3]
step_ls30 = [0, 0, 0, 3, 3, 3, 3, 3, 0, 0, 3, 3, 3, 1, 1, 2, 1, 1, 1, 1, 0, 0, 0, 0, 3, 3, 1, 1, 1, 1, 0, 0, 0, 0, 2, 0,
             0, 3, 0, 0, 0, 0, 2, 2, 2, 1, 1, 3, 0, 3, 1]
step_ls31 = [0, 0, 0, 0, 1, 1, 1, 1]
step_ls32 = [2, 2, 2, 3, 3, 3]
step_ls33 = [1, 1, 0, 0, 2, 2, 2, 1, 1, 2, 1, 1, 3, 3]
step_ls34 = [2, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 3, 3, 3]
step_ls35 = [0, 2, 0, 0, 2, 2, 1, 1, 1, 2, 2, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 3, 0, 2, 0, 3]
step_ls36 = [1, 1, 1, 2, 2, 2, 2, 0, 0, 0, 0, 2, 3, 3]
step_ls37 = [2, 2, 2, 2, 3, 0]
step_ls38 = [2, 2, 0, 0, 3, 3, 3, 3, 3, 3, 0, 0, 3, 3, 0, 1, 2, 2, 2, 2, 0, 0, 3, 2, 1, 1, 3, 3, 1, 1, 2, 2, 2, 2, 2, 2,
             0, 0, 3, 3, 0, 0, 2]
step_11_12 = [3, 3, 3, 3, 3, 3, 3, 3, 3]
step_ls39 = [0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 1, 1, 1, 1, 3, 3, 3, 3, 1, 1, 1, 1, 0, 0, 0, 0, 2, 0, 0, 2, 0, 0, 3, 3,
             1, 2]
step_ls40 = [3, 0, 0, 2, 2, 0, 0]
step_13_14 = [3, 3, 3, 3]
step_14_15 = [3, 3, 2, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2]
step_15_16 = [2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
              2, 2, 2]
step_ls41 = [0, 0, 2, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 3, 3, 0, 0, 0, 0, 0]
step_ls42 = [1, 1, 1, 1, 2]
step_ls43 = [0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 1, 1, 0, 0, 3, 0, 0, 3, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1,
             2, 2, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1]
step_12_13 = [2, 2, 2, 2, 2, 2, 2, 2, 2]
step_ls44 = [0, 0, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1,
             0, 0, 0, 0, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 0, 0, 2, 3, 0, 0, 0, 0, 1, 2]
step_ls45 = [3, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 3, (13,), 3, 3, 3, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 1, 1,
             3, 3, 2, 2, 1, 1, 3, 3, 0, (13,), 3, 3, 3, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 1, 1, 1, 1, 1,
             1, 1, 1, 1, 1, 2, 2, 2]
step_ls46 = [3, 3, 3, 3, 0, 0, 3, 3, 0, 0, 3, 3, 0, 0, 3, 0, 2, 0, 0, 0, 3, 1]
step_ls47 = [2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, (14,), 0, 0, 0, 0]
step_16_17 = [1, 1, 1, 1, 1, 1, 1]
step_17_18 = [2, 2, 3, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1,
              3, 3, 0, 3, 3, 3, 3, 1, 1, 2, 2, 1, 1, 3, 3, 3, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]
step_ls48 = [3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3]
step_ls49 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
             3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1]
step_ls50 = [2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0]
step_ls51 = [2, 2, 2, 0, 0, 2, 3, 0, 0, 2, 2, 1, 0, 3, 3, 3, 3, 1, 1, 3, 3, 0, 0, 2, 3, 3, 3, 3, 3, 1, 0, 2, 2, 1, 1, 3,
             2, 1, 1, 3, 3, 0, 1, 1, 1, 1, 0, 2, 2, 1, 1, 3, 2, 1, 1, 3, 3, 0, 1, 2, 2, 2, 2, 0, 0, 2, 2, 1, 1, 3, 2, 2,
             2, 2, 2, 0, 1, 3, 3, 0, 0, 2, 3, 0, 0, 2, 2, 1, 0, 0, 0, 0, 1, 3]
step_ls52 = [3, 1, 1, 2, 1, 1, 3, 3, 3, 3]
step_ls53 = [2, 1, 1, 1, 3, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1]
step_ls54 = [2, 2, 2, 2, 0, 2, 3, 1, 1, 2, 0]  # 去23楼左
step_ls55 = [2, 2, 3, 0, 1, 1, 3, 1, 1, 1, 1, 1, 3, 2, 0, 2, 2, 0, 2, 2, 2, 2, 0, 1, 3, 3, 3, 3, 1, 1, 2, 2, 2, 2, 2, 2,
             2, 0, 0, 0, 0, 3, 0, 3, 3, 3, 2, 2, 2, 0, 2, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 1, 1, 2, 2, 2, 2, 1, 0, 3, 3,
             3, 3, 0, 3, 3, 0, 3, 2, 1, 1, 1, 1, 1, 3, 3, 0, 3, 3, 3, 3]
step_ls56 = [3, 3, 3, 3, 0, 3, 2, 1, 1, 3, 0]  # 去23楼右
step_ls57 = [3, 3, 2, 0, 1, 1, 2, 1, 1, 1, 1, 1, 2, 3, 0, 3, 3, 0, 3, 3, 3, 3, 0, 1, 2, 2, 2, 2, 1, 1, 3, 3, 3, 3, 3, 3,
             3, 0, 0, 0, 0, 2, 0, 2, 2, 2, 3, 3, 3, 0, 3, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 1, 1, 3, 3, 3, 3, 1, 0, 2, 2,
             2, 2, 0, 2, 2, 0, 2, 3, 1, 1, 1, 1, 1, 2, 2, 0, 2, 2, 2, 2]
step_ls58 = [0, 0, 1, 0, 0, 2, 2, 3, 3, 3, 3, 2, 2, 0, 0, 0, 0]


def change_path_all(num):  # 返回相反操作
    if num in (0, 1):
        return 1 - num
    else:
        return 5 - num


def reverse_path(ls):  # 返回相反路径
    return list(map(change_path_all, ls))[-1::-1]


def change_left_to_down(num):
    dic = {0: 2, 1: 3, 2: 1, 3: 0}
    return dic[num]


def sysmetry_path(ls):  # 返回对称路径
    return list(map(change_left_to_down, ls))


step_ls = step_ls1 + step_1_2 + [1, (1,)] + step_ls2 + [(3,)] + step_3_4[:14] + step_ls3 + step_3_4[14:22] \
          + step_ls4 + step_ls5 + reverse_path(step_ls5) + reverse_path(step_3_4[14:22]) + step_ls6 \
          + step_3_4[14:22] + step_ls7 + step_3_4[22:-5] + reverse_path(step_3_4[22:-5]) + step_ls8 \
          + step_3_4[22:] + step_4_5[:24] + step_ls9 + step_4_5[26:] + step_5_6[:-3] + [1, 0] \
          + step_5_6[-3:] + step_6_7 + step_ls10 + [(1,)] + step_ls2[:-4] + [2, (5,)] + step_ls11[:10] \
          + [(1,)] + step_ls2[:-4] + step_ls12 + [(5,)] + step_ls11 + [0] + reverse_path(step_ls11[7:]) \
          + step_ls13 + [(1,)] + step_ls2[:5] + step_ls14 + [(5,)] + step_ls11[:7] + step_ls13[:3] \
          + step_ls15 + [(7,)] + step_ls16 + [(5,)] + step_ls17 + [(1,)] + step_1_2[:6] + step_ls18 \
          + [(4,)] + step_4_5[:25] + step_ls19 + [(7,)] + step_7_8 + [1, 1, 1, (4,)] \
          + reverse_path(step_4_5[25:]) + [0, 0, 0] + step_ls19 + [(8,)] + step_8_9[:-5] + step_ls20 \
          + reverse_path(step_ls20) + step_8_9[-5:] + step_ls21 + step_9_10[5:-2] + step_ls22 + step_10_11 \
          + step_ls23 + [(4,)] + reverse_path(step_4_5[25:]) + [0 for i in range(10)] + [(2,)] + step_ls24 \
          + [(5,)] + step_5_6[:-5] + [3, 3, (8,), 0] + step_ls25 + step_8_9[:31] + step_ls26 \
          + reverse_path(step_ls26) + step_ls27 + [(10,)] + step_ls28 + [(6,)] + step_ls29 + [(2,)] \
          + step_ls30 + [(7,)] + step_ls31 + step_7_8[:12] + step_ls32 + step_7_8[12:21] + step_ls33 + [(8,)] \
          + step_8_9[:31] + step_ls34 + [(6,)] + step_ls35 + [(9,)] + step_9_10[:-2] + step_ls36 + [(9,)] \
          + step_9_10[:10] + step_ls37 + [(10,)] + step_ls38 + [(11,)] + step_11_12[:-2] + step_ls39 \
          + [(13,)] + step_ls40 + reverse_path(step_ls40) + step_13_14 + step_14_15 + step_15_16[:19] \
          + step_ls41 + [(16,)] + step_ls42 + [(0,), 2, (11,)] + step_11_12[:-2] + step_ls43 + [(12,)] \
          + step_12_13[:4] + step_ls44 + [(13,)] + step_ls45 + [(12,)] + step_ls46 + [(14,)] + step_ls47 \
          + [(4,)] + reverse_path(step_4_5[25:]) + [0 for i in range(10)] + [(16,)] + step_16_17 \
          + step_17_18 + step_ls48 + step_ls49 + [(19,)] + step_ls50 + step_ls51 + [(7,)] + step_ls52 \
          + [(0,), 2, (20,)] + step_ls53 + step_ls54 + step_ls55 + step_ls56 + step_ls57 \
          + sysmetry_path(step_ls54) + sysmetry_path(step_ls55) + [0, 0, 0, 3, (23,), 0] + step_ls58
